<template>
	<view class="bgtmert">
		<uni-list>
			<uni-list-item title="账户与安全" @tap="hf('/pages/user/setting/AccountsAndSecurity')"></uni-list-item>
			<uni-list-item title="紧急联系人" @tap="hf('/pages/zhongjianbtn/aaEmergencyContact')"></uni-list-item>
			<uni-list-item title="非wifi环境下手动加载图片" :showArrow="false" :showSwitch="true"></uni-list-item>
			<uni-list-item title="清除缓存" :rightText="cachekey" @tap="qingchu"></uni-list-item>
			<uni-list-item title="关于科尼德" note="" @tap="hf('/pages/user/setting/InRegard')"></uni-list-item>
			<uni-list-item title="意见反馈" note="" @tap="hf('/pages/user/setting/feedback')"></uni-list-item>
		</uni-list>
		<view class="mt200 cen">
			<view class="njhhnjkxeer fz36 cf cen" @tap="unlogin()"> 
				退出登录
			</view>
		</view>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				cachekey:'1 KB',
				}
		},
		onLoad(){
			var self=this;
			 plus.cache.calculate( function ( size ) { //size是多少个字节单位是b
				 //你可以做下面相应的处理
				 if(size<1024){
					 self.cachekey=size+' B'; 
				 }  
				 else if(size/1024>=1 && size/1024/1024<1){
					  self.cachekey= Math.floor(size/1024*100)/100+' KB';
				 }
				else if(size/1024/1024>=1){
					 self.cachekey=Math.floor(size/1024/1024*100)/100+' M';
				}
			 });
		},
		components: {},
		methods: {
			qingchu(){
				let that =this
				//可以询问用户是否删除
				  uni.showModal({
					title:'提示',
					content:'确定清除缓存吗?',
					success(res) {
					   // 用户确定要删除
						if(res.confirm){
						   //使用plus.cache.clear 清除应用中的缓存数据 这里清除后还要二十几KB没有清除，达不到全部清除				
							
							plus.cache.clear( function () {
								//成功后处理
								that.cachekey = '0 KB'
								uni.showToast({
									title:'清除成功',
									icon:'none'
								})
							});	
						}
					}
				  })
			},
			tuichuwe(){
				uni.switchTab({
				    url: '/pages/user/index'
				});
			},
			unlogin(){
				let that = this
				//可以询问用户是否删除
			  uni.showModal({
				title:'提示',
				content:'确定退出登录吗?', 
				success(res) {
				   // 用户确定要删除
					if(res.confirm){
					   try {
					       uni.removeStorageSync('uid');
					       uni.removeStorageSync('uinfo');
					       uni.removeStorageSync('access_token');
					       uni.removeStorageSync('current');
					       uni.removeStorageSync('carmylist');
						   that.dqClear()
						   that.$store.commit('setisintcar', false)
						   uni.navigateTo({
						       url: '/pages/user/LoginAndRegistration'
						   });
					   } catch (e) {
						   uni.showToast({
						   	title:'出现错误，请稍候重试',
							icon:'none'
						   })
					       // error
					   }
					}
				}
			  })
				
			}
		},
		mounted() {}
	}
</script>
<style scoped>
	.njhhnjkxeer{
		width:560upx;
		height:120upx;
		line-height: 120upx;
		margin: auto;
		background:rgba(22,137,213,1);
		border:2upx solid rgba(22,137,213,1);
		box-shadow:0upx 6upx 12upx rgba(0,0,0,0.16);
		border-radius:60upx;
	}
</style>
